package com.hl.card.modular.pack.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.hl.card.common.persistence.dao.DisMemberInfoMapper;
import com.hl.card.common.persistence.model.DisMemberInfo;
import com.hl.card.modular.pack.service.DisMemberInfoService;
import com.hl.card.common.util.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DisMemberInfoServiceImp  extends ServiceImpl<DisMemberInfoMapper, DisMemberInfo> implements DisMemberInfoService{
    @Autowired
    private DisMemberInfoMapper disMemberInfoMapper;
    @Autowired
    private ResponseData responseData;
    /**
     * 合伙人的个人信息
     * @return
     */
    public DisMemberInfo queryDisMemberInfo(DisMemberInfo disMemberInfo) {

        return disMemberInfoMapper.queryDisMemberInfo( disMemberInfo);
    }
    @Override
    public DisMemberInfo selectDisMemberInfo(String disUserId, String disPayPassword) {
        DisMemberInfo dmi = new DisMemberInfo();
        dmi.setDisUserId(disUserId);
        dmi.setDisPayPassword(disPayPassword);
        return disMemberInfoMapper.selectDisMemberInfo(dmi);
    }
    @Override
    public ResponseData updateDisPayPasswordById(String disUserId, String newPassword) {
        DisMemberInfo dmi = new DisMemberInfo();

        dmi.setDisUserId(disUserId);
        dmi.setDisPayPassword(newPassword);
        int result=disMemberInfoMapper.updateDisPayPasswordById(dmi);
           if (result == 0) {
            responseData.setStatus("0");
            responseData.setData(null);
            responseData.setData("修改支付密码失败");
        } else {
            responseData.setData(dmi.getDisPayPassword());
            responseData.setStatus("1");
            responseData.setData("修改支付密码成功");
        }
         return responseData;

    }
    @Override
    public ResponseData saveDisPayPassword(String disUserId, String disPayPassword) {
          DisMemberInfo dmi = new DisMemberInfo();
        dmi.setDisUserId(disUserId);
        dmi.setDisPayPassword(disPayPassword);
         int result = disMemberInfoMapper.saveDisPayPassword(dmi);
        if (result == 0) {
            responseData.setStatus("0");
            responseData.setData(null);
            responseData.setData("修改支付密码失败");
        } else {
            responseData.setData(dmi.getDisPayPassword());
            responseData.setStatus("1");
            responseData.setData("修改支付密码成功");
        }
         return responseData;
    }

}
